/**
 * 				ClientTimerThreadItem.java
 *				------------
 *		
 *   Author:	bin04017@gmail.com
 *	 Created:	13.12.2006
 *	 Project:	MP3-Sync (Mochito)
 *	 Package:	mochito.clientClasses
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */
package mochito.clientClasses.clientTimer;

import java.util.Calendar;
import java.util.StringTokenizer;

import mochito.dataClasses.musicItem.MusicItem;

/**
 * @author bin04017
 * 
 */
public class ClientTimerThreadItem {
	private Calendar startTime = Calendar.getInstance();

	private boolean fired = false;

	private MusicItem item;

	public ClientTimerThreadItem() {
	}

	public ClientTimerThreadItem(String date, String time, MusicItem item) {
		StringTokenizer stringTokenizer = new StringTokenizer(date, "/", false);
		int year = Integer.parseInt(stringTokenizer.nextToken());
		int month = Integer.parseInt(stringTokenizer.nextToken());
		int day = Integer.parseInt(stringTokenizer.nextToken());

		stringTokenizer = new StringTokenizer(time, ":", false);
		int hour = Integer.parseInt(stringTokenizer.nextToken());
		int minute = Integer.parseInt(stringTokenizer.nextToken());
		int second = Integer.parseInt(stringTokenizer.nextToken());

		this.startTime.set(year, month - 1, day, hour, minute, second);

		this.item = item;
	}

	public MusicItem getMusicItem() {
		return this.item;
	}

	public boolean isFired() {
		return this.fired;
	}

	public boolean checkAlarm(Calendar now) {
		if (now.compareTo(startTime) >= 0) {
			this.fired = true;
			return true;
		}
		return false;
	}
}
